<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ include file="../../../../header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
[id^=gbox_] {
	margin: 0 auto;
}

.ui-pg-input {
	text-align: center
}

#btn-search {
	background: #009fff;
	border: blue;
}

td select {
	width: 50px;
}
</style>
</head>
<body>

	<div class="mod-toolbar-top cf" style="margin-top: 10px;">
		<div class="fr" style="margin-top: 30px;">
		    在职情况:<select id="isWork">
		        <option value="1">在职</option>
				<option value="0">离职</option>
				<option value="2">全部</option>
		    </select>&nbsp&nbsp&nbsp&nbsp
			公司： <select id="companyname"></select> 年份： <select id="years">
				<option value="2018">2018年</option>
				<option value="2019">2019年</option>
				<option value="2020">2020年</option>
				<option value="2021">2021年</option>
				<option value="2022">2022年</option>
			</select> <a href="javascript:void();" class="ui-btn ui-btn-sp mrb"
				id="btn-add">初始化</a> <a href="javascript:void();"
				class="ui-btn ui-btn-sp mrb" id="btn-search">搜索</a> 
				<a
				href="javascript:void();" class="ui-btn ui-btn-sp mrb" onclick="changData()">期初数据录入</a>
				<a
				href="javascript:void();" class="ui-btn ui-btn-sp mrb" onclick="testJqfrid()">提交</a>
			<a href="javascript:void();" class="ui-btn ui-btn-sp mrb"
				id="btn-search" onclick="checkInitData()">期初数据审核</a> <a href="javascript:void();"
				class="ui-btn ui-btn-sp mrb" onclick="abandonCheck()" id="btn-search">期初数据弃审</a>
            <a href="javascript:void();"
				class="ui-btn ui-btn-sp mrb" onclick="exportExcel()" id="btn-search">导出excel</a>
		</div>
	</div>
	<div class="grid-wrap" align="left" style="margin-left: 10px;"
		id="list2">
		<table id="grid1"></table>
		<div id="pager2"></div>
	</div>
	<div class="grid-wrap" align="left" style="margin-left: 10px;">
		<table id="grid2"></table>
	</div>
	<div class="grid-wrap" align="left" style="margin-left: 10px;">
		<table id="grid3"></table>
	</div>
	<script type="text/javascript">
	$.ajax({
		  type:"POST",
		  url:"company",
		  success:function(data){
			  var content = data;
			  $("#companyname").append(data);
		  }
	  });
	
	//导入excel表格
	function exportExcel(){
		var flag = window.confirm("确定要导出所有期初数据吗（依据在职公司年份进行筛选）");
		if(flag){
			window.location.href="/kaoqin/exportExcel?isWork="+$("#isWork").val()+"&years="+$("#years").val()+"&companyname="+$("#companyname").val();
		}
		
	}
	
	function mycallback(data) {
		if(data!=undefined){
			$('#grid1').jqGrid('setGridParam',{search:true});  
			$("#grid1").jqGrid("setGridParam",{postData:data}).jqGrid("setGridParam",{page:1}).trigger("reloadGrid");
		}else{
			$("#grid1").jqGrid().trigger("reloadGrid");
		}
	}
	
	$("#isWork").change(function(){
		var searchField= "work";
		var searchString=$("#isWork").val();
		var data={searchField:searchField,searchString:searchString,searchOper:"eq"};
		mycallback(data);
		
	});
	
	function update() {
		alert("update");
		$.ajax({
			url : "update",
			dataType : "json",
			success : function(data) {

			},
			erro : function() {
				alert("爆炸了！");
			}

		});
	}
	function deletes() {
		alert("update");
		$.ajax({
			url : "delete",
			dataType : "json",
			success : function(data) {

			},
			erro : function() {
				alert("爆炸了！");
			}
		});
	}
	function clearGrid() {
		$("#grid").jqGrid('clearGridData');
	}
		//添加图标
		function operationFormat(cellValue, options, rowObject) {
			return '<div class="operating" data-id="' + options.rowId + 
			'"><span class="ui-icon ui-icon-pencil" title="编辑" data-toggle="modal" data-target="#myModal"></span>&nbsp&nbsp'
			+ '<span class="ui-icon ui-icon-trash" title="删除"></span>';
		}
		$(function() {
			$("#grid1").jqGrid(
			{
				url : "/kaoqin/getAllPersonInit",
				mtype : "post",
				datatype : "json",
				height : 400,
				width : 1155,
				sortname : 'id',
				shrinkToFit : false,
				autoScroll : false,
				rownumbers : true,
				rowNum : -1,
				//cellEdit : true,
				cellsubmit : "clientArray",
				colNames : [ '操作','公司名称', '员工姓名', '年份', '上年假期', '本年假期',
				'上年加班数', '一月份上班','一月份请假','一月份有薪','二月份上班','二月份请假',
				'二月份有薪','三月份上班','三月份请假','三月份有薪','四月份上班','四月份请假','四月份有薪',
				'五月份上班','五月份请假','五月份有薪','六月份上班','六月份请假','六月份有薪','七月份上班',
				'七月份请假','七月份有薪','八月份上班','八月份请假','八月份有薪',
				'九月份上班','九月份请假','九月份有薪','十月份上班','十月份请假','十月份有薪','十一月份上班',
				'十一月份请假','十一月有薪','十二月份上班','十二月份请假','十二月份有薪',
				'上班总数','请假总数','有薪总数','实休年假','剩余年假','调休合计','法定假合计','病假合计',
				'事假合计','一月份Kpi','二月份Kpi','三月份Kpi','四月份Kpi','五月份Kpi',
				'六月份Kpi','七月份Kpi','八月份Kpi','九月份Kpi','十月份Kpi','十一月份Kpi','十二月份Kpi',
				'备注一','备注二','备注三'
				],
				colModel : [ {
					name : 'id',
					index : 'id',
					width : 70,
					formatter : operationFormat,
					align : "center",
					hidden:true,
					frozen:true,
					sortable : false
				},{
					name : 'companyName',
					index : 'companyName',
					align : "center",
					width : 80,
					searchoptions : {
					sopt : [ 'cn' ]
					},
							frozen:true
						}, {
							frozen:true,
							name : 'personName',
							index : 'personName',
								width : 80,
							align : "center",
							editable : false,
							editoptions : {
								size : 10
							},
							searchoptions : {
								sopt : [ 'cn' ]
							},
						}, {
							name : 'kjYear',
							index : 'kjYear',
								width : 80,
							align : "center",
							editable : false,
							editoptions : {
								size : 10
							},
							search : false,
						}, {
							name : 'holidaysStart',
							index : 'holidaysStart',
								width : 80,
							align : "center",
							editable : false,
							editoptions : {
								size : 10
							},
							search : false,
						}, {
							name : 'holidays',
							index : 'holidays',
									width : 80,
							align : "center",
							editable : false,
							editoptions : {
								size : 10
							},
							search : false,
						}, {
							name : 'overTimeDaysStart',
							index : 'overTimeDaysStart',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						}, {
							name : 'workDays01',
							index : 'workDays01',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						{
							name : 'offDays01',
							index : 'offDays01',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						{
							name : 'salaryDays01',
							index : 'salaryDays01',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays02',
							index : 'workDays02',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays02',
							index : 'offDays02',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays02',
							index : 'salaryDays02',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays03',
							index : 'workDays03',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays03',
							index : 'offDays03',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						
						{
							name : 'salaryDays03',
							index : 'salaryDays03',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays04',
							index : 'workDays04',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						{
							name : 'offDays04',
							index : 'offDays04',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						
					

						{
							name : 'salaryDays04',
							index : 'salaryDays04',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays05',
							index : 'workDays05',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays05',
							index : 'offDays05',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays05',
							index : 'salaryDays05',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays06',
							index : 'workDays06',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						{
							name : 'offDays06',
							index : 'offDays06',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays06',
							index : 'salaryDays06',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays07',
							index : 'workDays07',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},

						{
							name : 'offDays07',
							index : 'offDays07',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays07',
							index : 'salaryDays07',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays08',
							index : 'workDays08',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays08',
							index : 'offDays08',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays08',
							index : 'salaryDays08',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays09',
							index : 'workDays09',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays09',
							index : 'offDays09',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays09',
							index : 'salaryDays09',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays10',
							index : 'workDays10',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays10',
							index : 'offDays10',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays10',
							index : 'salaryDays10',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays11',
							index : 'workDays11',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays11',
							index : 'offDays11',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays11',
							index : 'salaryDays11',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'workDays12',
							index : 'workDays12',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDays12',
							index : 'offDays12',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDays12',
							index : 'salaryDays12',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						
						{
							name : 'workDaysTotal',
							index : 'workDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'offDaysTotal',
							index : 'offDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'salaryDaysTotal',
							index : 'salaryDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'holidaysTotal',
							index : 'holidaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'holidaysEnd',
							index : 'holidaysEnd',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'overTimeDaysTotal',
							index : 'overTimeDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'lawDaysTotal',
							index : 'lawDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'sickDaysTotal',
							index : 'sickDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'personDaysTotal',
							index : 'personDaysTotal',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi01',
							index : 'kpi01',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi02',
							index : 'kpi02',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi03',
							index : 'kpi03',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi04',
							index : 'kpi04',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi05',
							index : 'kpi05',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi06',
							index : 'kpi06',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi07',
							index : 'kpi07',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi08',
							index : 'kpi08',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi09',
							index : 'kpi09',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi10',
							index : 'kpi10',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi11',
							index : 'kpi11',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'kpi12',
							index : 'kpi12',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'remark1',
							index : 'remark1',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'remark2',
							index : 'remark2',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						},
						{
							name : 'remark3',
							index : 'remark3',
								width : 80,
							editable : false,
							align : "center",

							editoptions : {
								size : 10
							},
							search : false,
						}
						],
						rowNum : 5,//一页显示多少条
						rowList : [ 5,10,20 ],//可供用户选择一页显示多少条
						pager : '#pager2',//表格页脚的占位符(一般是div)的id
						viewrecords : true,
						onSelectRow : function(rowid) { //点击表格中的某一行，触发事件，获得数据
							handle.viewDetail(rowid);
						},
						loadComplete : function() {
							loadover();
						},
						gridComplete : function() {
						},
						afterInsertRow : function() {
						},
						beforeEditCell : function(rowid, cellname, v, iRow,
							iCol) {
							lastrow = iRow;
							lastcell = iCol;
						}
					});
			initTableRow();
			initEvent();
		 $("#grid1").jqGrid('setGroupHeaders', {
			    useColSpanStyle: true, 
			    groupHeaders:[
			    {startColumnName: 'workDays01', numberOfColumns: 3, titleText: '<em>一月份</em>'},
			    {startColumnName: 'workDays02', numberOfColumns: 3, titleText: '<em>二月份</em>'},
			    {startColumnName: 'workDays03', numberOfColumns: 3, titleText: '<em>三月份</em>'},
			    {startColumnName: 'workDays04', numberOfColumns: 3, titleText: '<em>四月份</em>'},
			    {startColumnName: 'workDays05', numberOfColumns: 3, titleText: '<em>五月份</em>'},
			    {startColumnName: 'workDays06', numberOfColumns: 3, titleText: '<em>六月份</em>'},
			    {startColumnName: 'workDays07', numberOfColumns: 3, titleText: '<em>七月份</em>'},
			    {startColumnName: 'workDays08', numberOfColumns: 3, titleText: '<em>八月份</em>'},
			    {startColumnName: 'workDays09', numberOfColumns: 3, titleText: '<em>九月份</em>'},
			    {startColumnName: 'workDays10', numberOfColumns: 3, titleText: '<em>十月份</em>'},
			    {startColumnName: 'workDays11', numberOfColumns: 3, titleText: '<em>十一月份</em>'},
			    {startColumnName: 'workDays12', numberOfColumns: 3, titleText: '<em>十二月份</em>'},
			    ]  
			  });			
			$("#grid1").jqGrid('setFrozenColumns'); 
		})
		
		//设置每行的高度
		function loadover() {
			var grid = $("#grid1");
			var ids = grid.getDataIDs();
			for (var i = 0; i < ids.length; i++) {
				grid.setRowData(ids[i], false, {
					height : 35
				});
			}
		}
		function initTableRow() {
			for (var i = 1; i <= 4; i++) {
				jQuery("#grid1").jqGrid('addRowData', i, {});
			}
			loadover();
		}
		

		//日期格式化函数
		Date.prototype.Format = function (fmt) { 
			
		    var o = {  
		        "M+": this.getMonth() + 1, //月份   
		        "d+": this.getDate(), //日   
		        "h+": this.getHours(), //小时   
		        "m+": this.getMinutes(), //分   
		        "s+": this.getSeconds(), //秒   
		        "q+": Math.floor((this.getMonth() + 3) / 3), //季度   
		        "S": this.getMilliseconds() //毫秒   
		    };  
		    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
		    for (var k in o)  
		    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
		    return fmt;  
		} 
		
		//添加事件
		function initEvent() {
			$("#btn-add").click(function(a) {
                var years = $("#years").val();
                var companyname = $("#companyname").val();
                $.ajax({
                	data:{"years":years,"companyname":companyname},
                	type:"POST",
                	url:'kaoqin/initData',
                	success:function(data){
                		if(data.status==200){
                			alert("初始化成功");
                			window.location.href="${pageContext.request.contextPath}/kaoqin/enterKaoQin";
                		}
                		else if(data.status==500){
                			alert("初始化失败");
                		}
                		else if(data.status==400){
                			alert("该年份起始数据已经初始化");
                		}
                		else if(data.status==600){
                			alert("该公司没有员工，无需初始化");
                		}
                		else if(data.status==700){
                			alert("上半年12月份还没有月结，不能初始化");
                		}
                		else if(data.status==1000){
                			alert("当前用户没有权限");
                		}
                	}
                	
                })
			}), $("#btn-search").click(function(a){
				handle.search();
			}),$("#grid1").on("click", ".operating .ui-icon-pencil",
			function(a) {
				var rowid = $(this).parent().data("id");
				var rowdata = $("#grid1").jqGrid("getRowData", rowid);
				handle.operate("edit", rowid, rowdata);
			}), $("#grid1").on("click", ".operating .ui-icon-trash",
			function(a) {
				a.preventDefault();
				var rowid = $(this).parent().data("id");
				handle.del(rowid);
			}), $("#btn-record").click(function(a) {
				$("#grid1").jqGrid().trigger("reloadGrid");
			}), $("#btn-setsession").click(function(a) {
				$.ajax({
					url : encodeURI("user/setsession"),
					type : "POST",
					success : function(data) {
						alert(data);
					}
				});
			}), $("#btn-getsession").click(function(a) {
				$.ajax({
					url : encodeURI("user/getsession"),
					type : "POST",
					success : function(data) {
						alert(data);
					}
				});
			})
		}
		handle = {
			operate : function(oper, rowid, rowdata) {
				var title;
				var data = {};
				if ("add" == oper) {
					title = "新增";
					data = {
						operate : oper,
						callback : this.callback
					}
					this.dialog = $.dialog({
						title : title,
						data : data,
						content : "url:/addjsp",
						width : 500,
						height : 250,
						max : false,
						min : false,
						cache : false,
						lock : true
					});
				} else {
					title = "修改";
					data = {
						operate : oper,
						rowdata : rowdata,
						rowid : rowid,
						callback : this.callback
					}
					this.dialog = $.dialog({
						title : title,
						data : data,
						content : "url:/editjsp",
						width : 500,
						height : 250,
						max : false,
						min : false,
						cache : false,
						lock : true
					});
				}
				
			},
			search:function(){
				var grid=$("grid1");
				this.dialog = $.dialog({
					title : "搜索",
					data : {
						callback:this.callback,
						grid:grid,
						searchWork:$("#isWork").val()
					},
					content : "url:/kaoqin/searchjsp",
					width : 500,
					height : 250,
					max : false,
					min : false,
					cache : false,
					lock : true
				});
			},
			viewDetail:function(rowId){
				title = "请假详情";
				data = {
					operate : 'view',
					rowid : rowId,
					callback : this.callback
				}
				this.dialog = $.dialog({
					title : title,
					data : data,
					content : "url:/kaoqin/qingjiaDetails",
					width : 500,
					height : 250,
					max : false,
					min : false,
					cache : false,
					lock : true
				});
			},
			
			qichu:function(){
				var grid=$("#grid1");
				var mycompany=$("#companyname");
				var myyears=$("#years");
				this.dialog = $.dialog({
					title : "搜索",
					data : {
						callback:this.callback,
						grid:grid,
						mycompany:mycompany,
						myyears:myyears
					},
					content : "url:/kaoqin/enterInitData",
					width : 500,
					height : 250,
					max : false,
					min : false,
					cache : false,
					lock : true
				});
			},
			del : function(rowId) {
				$.dialog.confirm("删除的参数类型将不能恢复，请确认是否删除？", function() {
					/* Public.ajaxPost("category/deleteType", {
						id: rowId
					}, function(data) {
						alert(data);
						$("#grid1").jqGrid().trigger("reloadGrid");
					}); */
					$.ajax({
						url : encodeURI("/editEmploy?oper=del"),
						type : "POST",
						data : {
							"id" : rowId
						},
						success : function(data) {
							if(data.status==500){
								alert("该字段已被引用，不能删除");
							}
							$("#grid1").jqGrid().trigger("reloadGrid");
						}
						
					});
				});
			},
			callback : function(data) {
				if(data!=undefined){
					$('#grid1').jqGrid('setGridParam',{search:true});  
					$("#grid1").jqGrid("setGridParam",{postData:data}).jqGrid("setGridParam",{page:1}).trigger("reloadGrid");
				}else{
					$("#grid1").jqGrid().trigger("reloadGrid");
				}
			}
		};
	
		//获取所有行数据
    function testJqfrid(){

    var obj=$("#grid1").jqGrid("getRowData");
    var params = [];
    jQuery(obj).each(function(){
        var text = this.id;
        //期初数据记录id
        var myid = $(text).attr("data-id");
        //上年假期
        var holidays = this.holidaysStart;
        //上年加班数
        var kjyears = this.kjYear;
        var companyName = this.companyName;
        var OverTimeDaysStart = this.overTimeDaysStart;
        //kpi
        var kpi01 = this.kpi01;
        var kpi02 = this.kpi02;
        var kpi03 = this.kpi03;
        var kpi04 = this.kpi04;
        var kpi05 = this.kpi05;
        var kpi06 = this.kpi06;
        var kpi07 = this.kpi07;
        var kpi08 = this.kpi08;
        var kpi09 = this.kpi09;
        var kpi10 = this.kpi10;
        var kpi11 = this.kpi11;
        var kpi12 = this.kpi12;
        params.push({"id":myid,"companyName":companyName,"kjYear":kjyears,"holidaysStart":holidays,"overTimeDaysStart":OverTimeDaysStart,"kpi01":kpi01,"kpi02":kpi02,"kpi03":kpi03,"kpi04":kpi04,"kpi05":kpi05,"kpi06":kpi06,"kpi07":kpi07,"kpi08":kpi08,"kpi09":kpi09,"kpi10":kpi10,"kpi11":kpi11,"kpi12":kpi12});
    });
    $.ajax({
    	type:'POST',
    	data:JSON.stringify(params),
    	url:"/kaoqin/changeInitData",
    	dataType:'json',
    	cache:false,
    	contentType:'application/json',
    	success:function(data){
    		if(data.status==200){
    			alert("期初数据修改成功");
    		}
    		else if(data.status==400){
    			alert("该数据已经审核完成，不能修改");
    		}
    		else if(data.status==1000){
    			alert("当前用户没有权限");
    		}
    		else{
    			alert("未知错误");
    		}
    	}
    	
    })     


}
	//更改单元格为可编辑
	function changData(){
		handle.qichu();
		
		
	}
	//审核
	function checkInitData(){
		 var years = $("#years").val();
         var companyname = $("#companyname").val();
         $.ajax({
        	 data:{"years":years,"companyname":companyname},
        	 type:"post",
        	 url:"/kaoqin/check",
        	 success:function(data){
        		 if(data.status==200){
        			 alert("审核成功");
        		 }
        		 else if(data.status==400){
        			 alert("已经审核过了，无需再审");
        		 }
        		 else if(data.status==1000){
         			alert("当前用户没有权限");
         		 }
        		 else if(data.status==500){
        			 alert("该公司该年份期初数据还没有初始化！");
        		 }
        	 }
         })
	}
	
	//弃审
	function abandonCheck(){
		 var years = $("#years").val();
         var companyname = $("#companyname").val();
         $.ajax({
        	 data:{"years":years,"companyname":companyname},
        	 type:"post",
        	 url:"/kaoqin/abandonCheck",
        	 success:function(data){
        		 if(data.status==200){
        			 alert("弃审成功");
        		 }
        		
        		 else if(data.status==300){
        			 alert("已经弃审，不能进行操作");
        		 }
        		 else if(data.status==1000){
         			alert("当前用户没有权限");
         		}
        		 else if(data.status==500){
        			 alert("该公司该年份期初数据还没有初始化！");
        		 }
        	 }
         })
	}
		
	</script>
</body>
</html>